<?php
	
	if (!defined('EXPONENT')) exit('');
	exponent_flow_set(SYS_FLOW_PROTECTED);
	require_once(BASE."modules/formhelpermodule/formhelper.php");
	
	$id_cat = 0;
	if(isset($_REQUEST['id']))
	{
		$id_cat = intval($_REQUEST['id']);
	}
	
	$formhelper=new formhelper("surveymodule","_survey_manager_title","_view_survey_by_cat",$loc);
	$formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
	$formhelper->setGridOptions("height",800);
	$formhelper->setGridOptions("idField","id");
	$formhelper->setGridOptions("pagination",true);
	$formhelper->setGridOptions("pageNumber","1");
	$formhelper->setGridOptions("pageSize","20");
	$formhelper->setGridOptions("rownumbers",true);
	$formhelper->setGridID("survey_grid");
	
	$formhelper->setInitCallback("grid_load_done");
	$js=URL_FULL."modules/surveymodule/js/SurveyManager.js";
	$formhelper->addJS($js);
	
	$formhelper->setColumnType(1);
	$formhelper->addColumn(array("field"=>"name","title"=>"Name",'width'=>100));
	$formhelper->addColumn(array("field"=>"cat_name","title"=>"Category",'width'=>100));
	$formhelper->addColumn(array("field"=>"time_start","title"=>"Start",'width'=>100));
	$formhelper->addColumn(array("field"=>"time_end","title"=>"Finish",'width'=>100));
	$formhelper->addColumn(array("field"=>"username","title"=>"Creator",'width'=>100));
	$formhelper->addColumn(array("field"=>"is_active","title"=>"Active",'width'=>60));
	$formhelper->addColumn(array("field"=>"description","title"=>"Description",'width'=>120));
	$formhelper->addColumn(array("field"=>"frist_text","title"=>"Introduce",'width'=>120));
	$formhelper->addColumn(array("field"=>"view_count","title"=>"Views count",'width'=>80));
	$formhelper->addColumn(array("field"=>"finished_count","title"=>"Take Survey count",'width'=>80));
	
	
	$link_param = '/index.php?module=surveymodule&action=survey_getjson&ajax_action=1&id_cat='.$id_cat;
	$formhelper->setURLDataStream($link_param);
	
	$formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad");
	
	$toolbar_template=new template("surveymodule","_Survey_Manager_ToolbarHTML",$loc);
	$toolbar_template->register_permissions(array('administrate',"configure"),$loc);
	$toolbar_html=$toolbar_template->render();
	$formhelper->addToolbarHTML($toolbar_html);
	
	$formhelper->register_permissions(array('administrate',"configure"),$loc);
	$formhelper->output();
?>
